Skip to content

Temp celery switch for question moderation #6688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions kitsune/questions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import actstream
import actstream.actions
import waffle
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
Expand Down Expand Up @@ -190,6 +191,7 @@ def clear_cached_contributors(self):

def save(self, update=False, *args, **kwargs):
"""Override save method to take care of updated if requested."""

new = not self.id

if not new:
Expand All @@ -203,8 +205,18 @@ def save(self, update=False, *args, **kwargs):
# actstream
# Authors should automatically follow their own questions.
actstream.actions.follow(self.creator, self, send_action=False, actor_only=False)
# Either automatically classify the question or add it to the moderation queue
question_classifier.delay(self.id)
if waffle.switch_is_active("flagit-spam-autoflag"):
from kitsune.questions.utils import flag_question
from kitsune.users.models import Profile

flag_question(
self,
by_user=Profile.get_sumo_bot(),
notes="Automatically flagged for topic moderation: flagit-spam-autoflag is active",
)
else:
# Either automatically classify the question or add it to the moderation queue
question_classifier.delay(self.id)

def add_metadata(self, **kwargs):
"""Add (save to db) the passed in metadata.
Expand Down